package com.flexrrb.controls.tooltips
{
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	import mx.core.UIComponent;
	
	public class MouseFollowTooltip extends SimpleTooltip
	{
		public function MouseFollowTooltip()
		{
			super();
			offset = new Point(3, 3);
		}
		
		override public function set target(value:UIComponent):void
		{
			super.target = value;
			target.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove, false, 0, true);
		}
		
		private function onMouseMove(event:MouseEvent):void
		{
			this.x = event.stageX + offset.x;
			this.y = event.stageY + offset.y;
		}
		
		override public function setupPosition():void
		{
			this.x = stage.mouseX + offset.x;
			this.y = stage.mouseY + offset.y;
		}
	}
}